﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EZCRS.HCMS.Data;
using EZCRS.HCMS.Entity;

namespace EZCRS.HCMS.SqlClient
{
    public class sql_hcrs_commercial
    {
        string sqlstr = "";

        /// <summary>
        /// 返回商业区
        /// </summary>
        /// <param name="cityid">城市id 0为所有</param>
        /// <returns></returns>
        public List<HCRS_Commercial> getallcommercial(int cityid)
        {
            if (cityid > 0)
                sqlstr = "select * from HCRS_Commercial where cityid=" + cityid.ToString();
            else
                sqlstr = "select * from HCRS_Commercial";
            return ExecSql.GetTableList<HCRS_Commercial>(sqlstr);
        }

        /// <summary>
        /// 删除一条
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool delcommercial(int id)
        {
            if (ExecSql.SqlExecNoquery("delete from HCRS_Commercial where commercialid=" + id.ToString()) > 0)
                return true;
            else
                return false;
        }

        /// <summary>
        /// 返回一条信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HCRS_Commercial getitemcommercial(int id)
        {
            return new HCRS_Commercial(ExecSql.GetDataSet("select * from HCRS_Commercial where commercialid=" + id.ToString()).Tables[0].Rows[0]);
        }

        /// <summary>
        /// 新增或修改信息
        /// </summary>
        /// <param name="_commercial"></param>
        /// <returns></returns>
        public bool insertorupdate(HCRS_Commercial _commercial)
        {
            return ExecSql.InsertOrUpdateData<HCRS_Commercial>(_commercial);
        }
    }
}
